import cv2
import os
import numpy as np
from glob import glob
import pandas as pd



if __name__ == '__main__':
    origin_train = "/media/yaokun/Fast SSD/AI/Competition/iflytek/audio_cls/ESResNet/data/train/"
    origin_test1 = "/media/yaokun/Fast SSD/AI/Competition/iflytek/audio_cls/ESResNet/data/test/"

    #origin_testB = "/media/aipc/Fast SSD/AI/Competition/iflytek/农作物生长情况/Data/testB/"
   

    dest_train_csv = "./iflydata/train.csv"
    dest_test1_csv = "./iflydata/sample_submission.csv"
    dest_test1_csv2 = "./iflydata/sample_submission2.csv"
    
    #dest_testB_csv = "./iflydata/sample_submissionB.csv"


  
    rows_list = []
    for i in range(1,7):
        train_paths = origin_train + str(i)
        print(train_paths)
        for wav_path in glob(train_paths+'/*'):
            print(wav_path)
            wav_name = os.path.basename(wav_path)
           
            row_dict = {'file':'data/train/'+str(i)+'/'+wav_name, 'label':i }       
            #row_dict = {'image':'data/train/'+dest_name, '喷药': , '锄地': , '除草': , '插秧': }
            rows_list.append(row_dict)

    train_info = pd.DataFrame(rows_list)
    train_info.to_csv(dest_train_csv, index=False)



    test_info = pd.DataFrame(columns=['file','label'])
    for wav in glob(origin_test1+'/*.*'):
        test_info = test_info.append({'file': 'data/test/' + os.path.basename(wav), 'label':0  }, ignore_index=True)
    test_info.to_csv(dest_test1_csv,index=False)

    test_info2 = pd.DataFrame(columns=['file','label1','label2', 'label3', 'label4', 'label5', 'label6'])
    for wav in glob(origin_test1+'/*.*'):
        test_info2 = test_info.append({'file': 'data/test/' + os.path.basename(wav), 'label1':0, 'label2':0 , 'label3':0 , 'label4':0,'label5':0, 'label6':0}, ignore_index=True)
    test_info2.to_csv(dest_test1_csv2,index=False)

    '''
    testB_info = pd.DataFrame(columns=['image','生长', '开花', '结果', '成熟'])
    for img in glob(origin_testB+'/*.*'):
        testB_info = testB_info.append({'image': 'testB/' + os.path.basename(img), '生长':0 , '开花':0 , '结果':0 , '成熟':0 }, ignore_index=True)
    testB_info.to_csv(dest_testB_csv,index=False)
    '''



